import pandas as pd
import numpy as np
import matplotlib.pylab as plt
import os

FILE_PATH = r'E:\gitee\ml-100k'
# 读入数据
u_cols = ['user_id', 'age', 'sex', 'occupation', 'zip_code']
users = pd.read_csv(os.path.join(FILE_PATH, 'u.user'), sep='|', names=u_cols, encoding='latin-1')

r_cols = ['user_id', 'movie_id', 'rating', 'unix_timestamp']
ratings = pd.read_csv(os.path.join(FILE_PATH, 'u.data'), sep='\t', names=r_cols, encoding='latin-1')

m_cols = ['movie_id', 'title', 'release_date', 'video_release_date', 'imdb_url']
movies = pd.read_csv(os.path.join(FILE_PATH, 'u.item'), sep='|', names=m_cols, usecols=range(5), encoding='latin-1')

# 数据集整合
movie_ratings = pd.merge(movies, ratings)
lens = pd.merge(movie_ratings, users)


